Ext.define('PrjAPLean.view.paapply.PaApplyManagePanel', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.paapplymanagepanel',

    requires: [
        'PrjAPLean.view.paapply.PaApplyManagePanelViewController',
        'PrjAPLean.view.paapply.PaApplyManagePanelViewModel',
        'Ext.form.Panel',
        'Ext.form.RadioGroup',
        'Ext.form.field.Radio',
        'Ext.form.field.Date',
        'Ext.toolbar.Toolbar',
        'Ext.button.Button',
        'Ext.grid.Panel',
        'Ext.grid.column.Check',
        'Ext.grid.column.Boolean',
        'Ext.grid.View',
        'Ext.grid.column.Date'
    ],
    
    viewModel: {
        type: 'paapplymanagevm'
    },
    controller:'paapplymanagevc',
    closable: true,
    itemId: 'paapplymanagepanel',
    layout: {
        type: 'vbox',
        align: 'stretch'
    },
    items: [ {
            xtype:'form',
            layout: 'column',
            border: false,
            bodyPadding: 10,
            title: '',
            items: [
	                {
	                    xtype: 'container',
	                    margin: '10 10',
	                    items: [{
                            xtype: 'container',
                            layout : 'hbox',
                            margin: '5 5',
                            items: [ {
									  	xtype: 'textfield',
										fieldLabel: '项目编号',
										labelAlign:'right',
										name:'modelCode'
									},
	    					        {
									  	xtype: 'textfield',
										fieldLabel: '项目名称',
										labelAlign:'right',
										name:'modelCode'
									},
	    					        {
									  	xtype: 'textfield',
										fieldLabel: '项目Owner',
										labelAlign:'right',
										name:'modelCode'
									}
	                            ]
	                        },
							{
	                            xtype: 'container',
	                            layout : 'hbox',
	                            margin: '5 5',
	                            items: [
	        						{
	    					        	xtype: 'combobox',
	    					            fieldLabel: '年',
	    					            labelAlign:'right',
	    					            name:'year',
	    					            itemId:'year',
	    					            displayField: 'name',
	    					            valueField: 'id',
	    					            editable: false,
	    					            value : new Date().getFullYear(),
	    					            store: Ext.create('Ext.data.Store',{
	    					            	fields: ['id', 'name'],
	    					                data : [
	    					                    {"id":"2015", "name":"2015"},
	    					                    {"id":"2016", "name":"2016"},
	    					                    {"id":"2017", "name":"2017"},
	    					                    {"id":"2018", "name":"2018"},
	    					                    {"id":"2019", "name":"2019"},
	    					                    {"id":"2020", "name":"2020"},
	    					                    {"id":"2021", "name":"2021"},
	    					                    {"id":"2022", "name":"2022"},
	    					                    {"id":"2023", "name":"2023"},
	    					                    {"id":"2024", "name":"2024"},
	    					                    {"id":"2025", "name":"2025"}
	    					            ]})
	    					        },
	    					        {
	    	                            xtype: 'container',
	    	                            layout : 'hbox',
	    	                            items: [
	    	        						{
	    	    					        	xtype: 'combobox',
	    	    					            fieldLabel: '月',
	    	    					            labelAlign:'right',
	    	    					            name:'month',
	    	    					            itemId:'month',
	    	    					            displayField: 'name',
	    	    					            valueField: 'id',
	    	    					            editable: false,
	    	    					            value : new Date().getMonth() + 1,
	    	    					            store: Ext.create('Ext.data.Store',{
	    	    					            	fields: ['id', 'name'],
	    	    					                data : [
	    	    					                    {"id":"1", "name":"01"},
	    	    					                    {"id":"2", "name":"02"},
	    	    					                    {"id":"3", "name":"03"},
	    	    					                    {"id":"4", "name":"04"},
	    	    					                    {"id":"5", "name":"05"},
	    	    					                    {"id":"6", "name":"06"},
	    	    					                    {"id":"7", "name":"07"},
	    	    					                    {"id":"8", "name":"08"},
	    	    					                    {"id":"9", "name":"09"},
	    	    					                    {"id":"10", "name":"10"},
	    	    					                    {"id":"11", "name":"11"},
	    	    					                    {"id":"12", "name":"12"},
	    	    					            ]})
	    	    					        }
	    	                            ]
	    	                        }
	                            ]
	                        }
	                    ]
	                }
                
            ],
            dockedItems: [
  	                {
  	                    xtype: 'toolbar',
  	                    dock: 'bottom',
  	                    border: 0,
  	                    layout: {
  	                        type: 'hbox'
  	                    },
  	                    items: [
  							{
  							    xtype: 'button',
  							    iconCls: 'common-icon-serach',
  							    text: '查询',
  							    handler:'onQueryClick'
  							},
  	                        {
  	                            xtype: 'button',
  	                            iconCls: 'common-icon-add',
  	                            text: '新建',
  	                            handler:'onCreateClick'
  	                        },
  	                        {
  	                            xtype: 'button',
  	                            iconCls: 'common-icon-delete',
  	                            text: '删除',
  	                            handler:'onDeleteClick'
  	                        }
  	                    ]
  	                }
                  ]
        },{
            xtype: 'gridpanel',
            flex: 4,
            //bind:'{paapply}',
            itemId:'paapplypanel',
            reference: 'paapplyGrid',
            viewConfig: {
                enableTextSelection: true
             },
            listeners: {
  			    rowdblclick : 'onRowClick'
  			},
            columns: [
                  {
                	  xtype: 'gridcolumn',
                      dataIndex: 'id',
                      itemId:'id',
                      hidden: true,
                      text: 'id',
                      align: 'left' 
                  },
                  {
                	  xtype:'gridcolumn',
                	  dataIndex:'code',
                	  text:'项目编号',
                	  align:'left'
                  },
                  {
                  	  xtype:'gridcolumn',
                  	  dataIndex:'projectName',
                  	  text:'项目名称',
                  	  align:'left'
                  },
                  {
                  	  xtype:'gridcolumn',
                  	  dataIndex:'status',
                  	  text:'状态',
                  	  align:'left'
                  },
                  {
                	  xtype: 'gridcolumn',
                	  width: 140,
                	  dataIndex: 'activityperiodStart',
                	  text: '活动开始日期',
                	  align: 'left' 
                  },
                  {
                	  xtype: 'gridcolumn',
                	  width: 120,
                	  dataIndex: 'activityperiodEnd',
                	  text: '活动结束日期',
                	  align: 'left' 
                  },
                  {
                	  xtype: 'gridcolumn',
                	  width: 140,
                	  dataIndex: 'applier',
                	  text: '申请人',
                	  align: 'left'
                  },
                  {
                	  xtype: 'gridcolumn',
                	  width: 120,
                	  dataIndex: 'owner',
                	  text: '项目Owner',
                	  align: 'left'
                  },
                  {
                	  xtype: 'gridcolumn',
                	  width: 140,
                	  dataIndex: 'amount',
                	  text: '项目总金额',
                	  align: 'left'
                  }
            ],
            dockedItems: [
                  {
    			        xtype: 'pagingtoolbar',
    			        dock: 'bottom',
//    			        bind: {
//    				        store: '{paapply}'
//    				    },
    			        displayInfo : true,
    					displayMsg:'显示 {0} - {1}条记录，总共 {2}条记录',
    					emptyMsg:'暂无数据',
    					beforePageText:'页数',
    					afterPageText:'总共{0}页',
    					firstText:'第一页',
    					prevText:'上一页',
    					nextText:'下一页',
    					lastText:'最后一页',
    					width:'100%',
    					emptyMsg : '没有记录'
    			    }                          
              ]
        }
    ]
});